
public class TestSort {
	public static void main(String[] args) {
		Cat[] cs = {new Cat("小花",22),
				new Cat("小黄",12),
				new Cat("大华",33),
				new Cat("大黄",15),
				new Cat("小小",5)};
		sort(cs);
		for(Cat c:cs) {
			System.out.println(c);
		}
	}
	
	public static void sort(Cat []cs) {
		for(int i=cs.length-1;i>0;i--) {
			for(int j=0;j<i;j++) {
				if(cs[j].size>cs[j+1].size) {
					Cat tc = cs[j];
					cs[j] = cs[i];
					cs[i] = tc;
				}
			}
		}
	}
}

class Cat {
	String name;
	int size;
	
	public Cat(String name,int size) {
		this.name = name;
		this.size = size;
	}

	@Override
	public String toString() {
		return "Cat [name=" + name + ", size=" + size + "]";
	}
} 